home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / aros / source / exec / library / src / makefunctions.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-16  |  2.3 KB  |  104 lines

  1. /*
  2.     (C) 1995, 96 AROS - The Amiga Replacement OS
  3.     $Id$
  4.     $Log$
  5.     Desc:
  6.     Lang: english
  7. */
  8. #include "exec_intern.h"
  9. #include <aros/lvo.h>
  10.  
  11. /*****************************************************************************
  12.  
  13.     NAME */
  14.     #include <clib/exec_protos.h>
  15.  
  16.     __AROS_LH3(ULONG, MakeFunctions,
  17.  
  18. /*  SYNOPSIS */
  19.     __AROS_LA(APTR, target,        A0),
  20.     __AROS_LA(APTR, functionArray, A1),
  21.     __AROS_LA(APTR, funcDispBase,  A2),
  22.  
  23. /*  LOCATION */
  24.     struct ExecBase *, SysBase, 15, Exec)
  25.  
  26. /*  FUNCTION
  27.     Creates the jumptable for a shared library and flushes the processor's
  28.     instruction cache. Does not checksum the library.
  29.  
  30.     INPUTS
  31.     target          - The highest byte +1 of the jumptable. Typically
  32.             this is the library's base address.
  33.     functionArray - Pointer to either an array of function pointers or
  34.             an array of WORD displacements to a given location
  35.             in memory. A value of -1 terminates the array in both
  36.             cases.
  37.     funcDispBase  - The base location for WORD displacements or NULL
  38.             for function pointers.
  39.  
  40.     RESULT
  41.     Size of the jumptable.
  42.  
  43.     NOTES
  44.  
  45.     EXAMPLE
  46.  
  47.     BUGS
  48.  
  49.     SEE ALSO
  50.  
  51.     INTERNALS
  52.  
  53.     HISTORY
  54.  
  55. ******************************************************************************/
  56. {
  57.     __AROS_FUNC_INIT
  58.  
  59.     /* Cast for easier access */
  60.     LVEntry *jv=(LVEntry *)target;
  61.  
  62.     if(funcDispBase!=NULL)
  63.     {
  64.     /* If FuncDispBase is non-NULL it's an array of relative offsets */
  65.     WORD *fp=(WORD *)functionArray;
  66.  
  67.     /* -1 terminates the array */
  68.     while(*fp!=-1)
  69.     {
  70.         /* Decrement vector pointer by one and install vector */
  71.         jv--;
  72.         jv->lve_Jmp = M68k_JMP;
  73.         jv->lve_FuncPtr = (APTR) ((UBYTE *)funcDispBase + *fp);
  74.  
  75.         /* Use next array entry */
  76.         fp++;
  77.     }
  78.     }else
  79.     {
  80.     /* If FuncDispBase is NULL it's an array of function pointers */
  81.     void **fp=(void **)functionArray;
  82.  
  83.     /* -1 terminates the array */
  84.     while(*fp!=(void *)-1)
  85.     {
  86.         /* Decrement vector pointer by one and install vector */
  87.         jv--;
  88.         jv->lve_Jmp = M68k_JMP;
  89.         jv->lve_FuncPtr = (APTR) *fp;
  90.  
  91.         /* Use next array entry */
  92.         fp++;
  93.     }
  94.     }
  95.  
  96.     /* Clear instruction cache for the whole jumptable */
  97.     CacheClearE(jv,(BYTE *)funcDispBase-(BYTE *)jv,CACRF_ClearI);
  98.  
  99.     /* Return size of jumptable */
  100.     return (ULONG)((BYTE *)funcDispBase-(BYTE *)jv);
  101.     __AROS_FUNC_EXIT
  102. } /* MakeFunctions */
  103.  
  104.